import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;

import java.io.IOException;

/**
 * @author tbc on 2016/12/3 0:51.
 */
public class OkWSL {
    public static void main(String[] args) throws IOException {
        String host = "";
        int port = 7006;
        String path = "";
        String url = "http://dms.jiangxi-isuzu.cn:7006/prd/dms.do?1=1";

//        GET /prd/index_login.jsp?message=system.user.errors.password HTTP/1.1
//        Host: dms.jiangxi-isuzu.cn:7006
//        Connection: keep-alive
//        Cache-Control: max-age=0
//        Upgrade-Insecure-Requests: 1
//        User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
//        Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
//Referer: http://dms.jiangxi-isuzu.cn:7006/prd/index_login.jsp?message=system.user.errors.password
//Accept-Encoding: gzip, deflate, sdch
//Accept-Language: zh-CN,zh;q=0.8
//Cookie: JSESSIONID=2TQhYBhSgrbb29pZC03TGXC1Kz2nrNNjzn7JnmdnnHVvVGdpQhGz!-1863235506


        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(url)
                .addHeader("Content-Type", "application/x-www-form-urlencoded")
                .addHeader("Cookie", "JSESSIONID=2TQhYBhSgrbb29pZC0dsXC1Kz2nrNNjzn7JnmdnnHVvVGdpQhGz!-1863235506")
                .build();
        Response response = client.newCall(request).execute();
        ResponseBody responseBody = response.body();
        System.out.println("code: " + response.code() + ",  isOk: " + response.isSuccessful());
        System.out.println(response.message());
        System.out.println(response.headers());
    }
}
